// Root Scene Node
// (c) jimon game studio

#include "CRootSceneNode.h"

namespace je
{
	namespace scene
	{
		//! Constructor
		CRootSceneNode::CRootSceneNode(video::IRender * Render)
			:ISceneNode(Render,"RootSceneNode")
		{
		}

		//! Destructor
		CRootSceneNode::~CRootSceneNode()
		{
		}

		//! On Update
		void CRootSceneNode::OnUpdate()
		{
			OnUpdate(this);
			ISceneNode::OnUpdate();
		}

		//! On Visibility Culling
		void CRootSceneNode::OnVisibilityCulling()
		{
			OnVisibilityCulling(this);
			ISceneNode::OnVisibilityCulling();
		}

		//! On Update
		void CRootSceneNode::OnUpdate(ISceneNode * Node,u1 UpdateSelf)
		{
			if(UpdateSelf)
				Node->OnUpdate();
			for(ChildrensListType::Iterator Iter = Node->GetChildrensList().begin();Iter!=Node->GetChildrensList().end();Iter++)
				OnUpdate(*Iter,true);
		}

		//! On Visibility Culling
		void CRootSceneNode::OnVisibilityCulling(ISceneNode * Node,u1 UpdateSelf)
		{
			if(UpdateSelf)
				if(Node->IsVisible())
					Node->OnVisibilityCulling();
				else
					Node->SetInFrame(false);

			for(ChildrensListType::Iterator Iter = Node->GetChildrensList().begin();Iter!=Node->GetChildrensList().end();Iter++)
				OnVisibilityCulling(*Iter,true);
		}

		//! Serialize
		void CRootSceneNode::Serialize(core::ISerializeStream * SerializeStream)
		{
			ISceneNode::Serialize(SerializeStream);
		}

	}
}
